﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using log4net;

namespace Dazaza.Framework
{
    public class Log
    {
        private string LogName { get; set; }
        private static Log _log;
        private static readonly object lockObject = new object();
        protected Log()
        {
            LogName = "Logger";
            this.Logger = LogManager.GetLogger(LogName);
        }
        protected Log(string logName)
        {
            LogName = logName;
            this.Logger = LogManager.GetLogger(LogName);
        }
        public ILog Logger { get; set; }
        public static ILog GetLogger()
        {
            lock (lockObject)
            {
                if (_log == null)
                {
                    if (Vjia.Framework.Configuration.ConfigMananger.WebSiteConfig == null)
                    {
                        _log = new Log();
                    }
                    else
                    {
                        _log = new Log(Vjia.Framework.Configuration.ConfigMananger.WebSiteConfig.SiteName);
                    }
                }
            }
            return _log.Logger;
        }
        public static ILog GetLogger(string LogName)
        {
            lock (lockObject)
            {
                if (_log == null)
                {
                    _log = new Log(LogName);
                }
            }
            return _log.Logger;
        }
    }
}
